//@version: $Id: Global.h 138 2010-12-09 00:05:57Z shoutingchief@gmail.com $

#pragma once
#include <windows.h>
#include <stdio.h>
#include "Map.h"
#include "renderer.h"
#include "UserInput.h"
#include "Global.h"

class Game
{
private:
	UserInput ui;//ui object
	Map Board;
public:
	Game()//default constructor
	{
	}
	void DrawAll(){Board.drawAll();}
	void HandleInput(){
		if(ui.isThereAClick())
		{
			Board.handleInput(ui);
		}
		ui.releasedButton();
	}

	bool gameover() //stubbed
	{

		//counter so it tests gameover eventually
		static int temp_counter = 0;
		temp_counter++;

		//if(temp_counter < NUMBER_OF_TIMES_GAME_RUNS)

		//if(temp_counter < 2)

			//return true;
		//else
			//return false;

		Board.comboRenew();
		return Board.check();

	}
	void update(bool &acceptable)//stubbed
	{
		DrawAll();
		HandleInput();
		if(!gameover())
			acceptable = false;
		else
			acceptable = true;
	}
	
	bool initmap()
	{
		
		Renderer::Instance()->SetViewPoint(D3DXVECTOR3(0.0f,0.0f,-13.25f));
		Renderer::Instance()->SetTarget(cvOrigin);
		Renderer::Instance()->InitializeDemo();
		Board.init();
		return true;
	}

	bool initgame(HWND wndHandle)//initializes renderer and map
	{
		Renderer::Instance()->InitializeD3D(wndHandle);
		//Renderer::Instance()->InitializeDemo();

		if(initmap())
			return true;
		else
			return false;
	}
	//cahnged the return type to change the real information not just imagine that it would change
	UserInput* getUIObject() { return &ui; }//returns the ui object for the main to use, i didnt know another way to do this.
	Map* getMapObject() {return &Board;}	//returns the map object for main to use
};